import { Directive, Input } from "@angular/core";
import {
  ValidatorFn,
  AbstractControl,
  NG_VALIDATORS,
  Validator
} from "@angular/forms";

@Directive({
  selector: "[appConfirmPassword]",
  providers: [
    {
      provide: NG_VALIDATORS,
      useExisting: ConfirmPasswordDirective,
      multi: true
    }
  ]
})
export class ConfirmPasswordDirective implements Validator {
  @Input() inputValue: string;
  constructor() {}

  validate() {
    return null;
  }
}

export function passwordValidator(): ValidatorFn {
  return (control: AbstractControl): { [key: string]: any } | null => {
    const value = control.value;
    return null;
  };
}
